package gui.screens;

import gui.CanvasManager;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * Class for the shot screen.
 * @author Sandra Mayer
 *
 */
public class ShotScreen extends Canvas implements CommandListener {

	private static String FILENAME = "/shot.jpg";
	private Command okCmd;
	private Image rabbit;
	
	/**
	 * Constructor.
	 */
	public ShotScreen() {
		try {
			rabbit = Image.createImage(FILENAME);
		} catch (Exception e) {
			e.printStackTrace();
		}
		okCmd = new Command("Ok", Command.OK, 0);
		this.addCommand(okCmd);
		this.setCommandListener(this);
	}

	/**
	 * Does the command action.
	 */
	public void commandAction(Command cmd, Displayable arg1) {
		if (cmd == okCmd) {
			CanvasManager.showCanvas();
		}
	}
	
	/**
	 * Paints the screen.
	 * @param g Graphics
	 */
	protected void paint(Graphics g) {
		g.setColor(0xffffff);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.translate((getWidth() - rabbit.getWidth()) / 2,
				(getHeight() - rabbit.getHeight()) / 2);

		g.drawImage(rabbit, 0, 0, Graphics.TOP | Graphics.LEFT);
	}
}
